<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Rag Hu
 * Created Time: 2019/7/26 9:43
 * Modified Time: 2019/7/26 9:43
 * Version: 2.0
 */

namespace App\Modules\Partner\Criterias;


use App\Lib\Facades\FLAuth;
use Flower\Core\Repository\Contracts\RepositoryInterface;
use Flower\Core\Repository\Criterias\BaseCriterias;
use function foo\func;
use Illuminate\Support\Facades\DB;

class GetInviteStoreRecordCriteria extends BaseCriterias
{
    private $requestData;

    public function __construct($requestData)
    {
        $this->requestData = $requestData;
    }

    public function apply($model, RepositoryInterface $repository)
    {
        $user_id = FLAuth::id();



        $model = $model
            ->select([
                'id',
                'new_user_id',
                'status',
                'amount',
                'created_at'
            ])
            ->with(['userStore'=>function($query){
                $query->select(['uid','sid'])
                    ->with(['store'=>function($query){
                    $query->select(['id','name']);
                }])
                ;
            }])
            ->where('user_id', $user_id);
        return $model;
    }
}